;##################################
;命令：
;nasm -f elf64 day4_0vector_1times.asm -o main.o && gcc main.o -o main -lc -no-pie && ./main
;输出：
;Value in arr[0] is 1.234500.
;Value in arr[1] is 2.345600.
;Value in arr[2] is 3.456700.
;Value in arr[3] is 4.567800.
;##################################
extern printf

section .data
	msg: db `Value in arr[%d] is %f.\n`, 0
	arr0: dd 0.1234, 1.2345, 2.3456, 3.4567
;####################################
	arr1: times 4 dd 1.1111
;####################################
section .text
	global main

main:
	push rbp
	mov rbp, rsp

	;向量加法
	vmovups xmm0, [arr0]
	vmovups xmm1, [arr1]
	vaddps xmm0, xmm0, xmm1
	vmovups [arr0], xmm0

	;打印
	mov ebx, 0
	jmp compare

execute:
	mov rdi, msg
	movsxd rsi, ebx
	cvtss2sd xmm0, dword [arr0 + 4 * ebx]
	movq rdx, xmm0
	call printf

	inc ebx

compare:
	cmp ebx, 4
	jl execute

	mov eax, 0
	leave
	ret
